"""
编写人:陈强
"""
# 引入模块
from ecshop.MY_ECShop.common.base import Base, create_loading_browser
import time


class PageDelVip(Base):
    # 定义属性
    url = "http://localhost:8080/ecshop/admin/index.php"
    vip_manage = ('xpath', '//*[@id="menu-ul"]/li[8]')
    vip_list = ('xpath', '//*[@id="sub-menu-03_users_list"]/a')
    del_button = ('xpath', '//*[@id="listDiv"]/table/tbody/tr[3]/td[10]/a[5]')
    del_vip_button = ('id', 'btnSubmit')
    del_text = ('xpath', '/html/body/h1/span[1]/a')
    # 定义方法
    """确定网页"""

    def page_del_open_web(self):
        self.base_open_web(self.url)

    """进入iframe标签"""

    def page_del_iframe(self, your_iframe):
        self.base_name_iframe_window(your_iframe)

    """退出iframe标签"""

    def page_del_quit_iframe(self):
        self.base_quit_all_iframe()

    """点击会员管理"""

    def page_del_click_manage(self):
        self.base_click(self.vip_manage)

    """点击会员列表"""

    def page_del_click_list(self):
        self.base_click(self.vip_list)

    """点击删除会员按钮"""

    def page_del_vip_button(self):
        self.base_click(self.del_vip_button)

    """点击移除按钮"""

    def page_del_button(self):
        self.base_click(self.del_button)

    """捕获弹窗并操作"""

    def page_del_alert(self):
        self.base_alert_accept()

    time.sleep(10)
    """获取文本"""

    def page_text(self):
        return self.base_get_text(self.del_text)

    """关闭"""

    def page_del_quit(self):
        self.base_quit_web()


if __name__ == '__main__':
    s1 = PageDelVip(create_loading_browser())
    s1.page_del_open_web()
    s1.page_del_iframe(0)
    s1.page_del_click_manage()
    s1.page_del_click_list()
    s1.page_del_quit_iframe()
    s1.page_del_iframe('main-frame')
    s1.page_del_button()
    s1.page_del_alert()
    print(s1.page_text())

